#
# php 7.3 Dockerfile
#

FROM php:7.3-apache

MAINTAINER Dongasai 1514582970@qq.com

# 开启伪静态
RUN a2enmod rewrite;
RUN apt-get update;apt-get install -y git vim wget zip zlib1g-dev libcurl4-openssl-dev pkg-config libssl-dev; 
# 安装常用扩展
RUN apt-get install -y libonig-dev
RUN docker-php-ext-install pdo pdo_mysql bcmath  mbstring;docker-php-ext-enable pdo pdo_mysql bcmath  mbstring;
RUN apt-get install -y \
		libfreetype6-dev \
		libjpeg62-turbo-dev \
		libpng-dev \
	&& docker-php-ext-install gd
	
RUN pecl install redis && docker-php-ext-enable redis 
RUN apt-get install -y libmemcached-dev zlib1g-dev 
RUN pecl install memcached && docker-php-ext-enable memcached

# 安装 composer
RUN wget https://mirrors.aliyun.com/composer/composer.phar \
	&& mv composer.phar /usr/local/bin/composer \
	&& chmod +x /usr/local/bin/composer \
	&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# 设置目录为public
COPY default.conf /etc/apache2/sites-enabled/000-default.conf

# 安装phalcon
ENV PHALCON_VERSION=3.4.5
RUN curl -sSL "https://codeload.github.com/phalcon/cphalcon/tar.gz/v${PHALCON_VERSION}" | tar -xz \
    && cd cphalcon-${PHALCON_VERSION}/build \
    && ./install \
    && cp ../tests/_ci/phalcon.ini $(php-config --configure-options | grep -o "with-config-file-scan-dir=\([^ ]*\)" | awk -F'=' '{print $2}') \
    && cd ../../ \
    && rm -r cphalcon-${PHALCON_VERSION}

# 安装protobuf
# wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-php-${PROTOBUF_VERSION}.tar.gz
ENV PROTOBUF_VERSION=3.14.0
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-php-${PROTOBUF_VERSION}.tar.gz \
    && tar -zxvf protobuf-php-${PROTOBUF_VERSION}.tar.gz \
    && cd protobuf-${PROTOBUF_VERSION} \
    && ./configure --prefix=/opt/soft/protobuf \
    && make \
    && make install

#重置工作目录
WORKDIR /var/www/html
RUN ls